package xupt.com.bolg.config;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import xupt.com.bolg.config.intercepors.LoginHandleIntercepors;
import xupt.com.bolg.config.intercepors.ManagerHandleIntercepors;

@Component
public class MyConfig implements WebMvcConfigurer {
    @Autowired
    LoginHandleIntercepors handleIntercepors;
    @Autowired
    ManagerHandleIntercepors managerHandleIntercepors;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(handleIntercepors).addPathPatterns("/*").excludePathPatterns("/","/index.html","/register","/register.html","/login","/sendEmailCode","/wangjimima**","/checkCode","/findPassword","/resetPassword","/getVerifyCode","/test/*","findPassword");
        registry.addInterceptor(managerHandleIntercepors).addPathPatterns("/manager/*");
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/main.html").setViewName("homepage");

    }

}
